package com.xunyji.demo00testdemo.repository;

import com.xunyji.demo00testdemo.model.weixin.WeixinAuthUserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author AltEnter
 * @create 2019-01-13 10:45
 * @desc 微信用户和网站用户关联持久层
 **/
public interface WeixinAuthUserRepository extends JpaRepository<WeixinAuthUserDO, Integer> {
    WeixinAuthUserDO findByOpenid(String openid);

    @Transactional(timeout = 10)
    @Modifying
    @Query("update WeixinAuthUserDO set password = :password where openid = :openid")
    Integer modifyPasswordByOpenid(@Param("password") String password, @Param("openid") String openid);
}
